package entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
@Entity
public class Kupac extends Korisnik{

	private List<Narudzbina> narudzbina=new ArrayList<Narudzbina>();
	
	@OneToMany(cascade = CascadeType.ALL,fetch=FetchType.EAGER)
	public List<Narudzbina> getNarudzbina() {
		return narudzbina;
	}

	public void setNarudzbina(List<Narudzbina> narudzbina) {
		this.narudzbina = narudzbina;
	}
	
	public Kupac() {
		super();
	}

	public Kupac(String koisnickoIme, String korisnickaSifra, String adresa) {
		setKoisnickoIme(koisnickoIme);
		setKorisnickaSifra(korisnickaSifra);
		setAdresa(adresa);
	}
	
	public void dodajNarudzbinu(Narudzbina pomNarudzbina)
	{
		if(narudzbina==null)
		{
			System.out.println("USLO");
			narudzbina=new ArrayList<Narudzbina>();
		}
		narudzbina.add(pomNarudzbina);
	}
	
	
}
